/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package systole.view.crud.tableModels;

import java.util.List;

import systole.domain.clinicalInformation.Pathology;

/**
 * 
 * @author jmj
 */
public class PathologiesTableModel extends SystoleTableModel<Pathology> {

    private String[] columnNames = {"Nombre", "Sigla", "Descripción"};
    private static final int NAME_INDEX = 0;
    private static final int INITIALS_INDEX = 1;
    private static final int DESCRIPTION_INDEX = 2;

    /**
     * @param patologies
     */
    public PathologiesTableModel(List<Pathology> patologies) {
        super(patologies);
    }

    public int getColumnCount() {
        return this.columnNames.length;
    }

    public String getColumnName(int column) {
        return this.columnNames[column];
    }

    public Class<?> getColumnClass(int column) {
        switch (column) {
            case NAME_INDEX:
                return String.class;
            case INITIALS_INDEX:
                return String.class;
            case DESCRIPTION_INDEX:
                return String.class;
        }
        return null;
    }

    public Object getValueAt(int row, int column) {
        switch (column) {
            case NAME_INDEX:
                return this.entities.get(row).getName();
            case INITIALS_INDEX:
                return this.entities.get(row).getInitials();
            case DESCRIPTION_INDEX:
                return this.entities.get(row).getDescription();
        }
        return null;
    }

    public void setValueAt(Object value, int row, int column) {
        switch (column) {
            case NAME_INDEX:
                this.entities.get(row).setName((String) value);
                break;
            case INITIALS_INDEX:
                this.entities.get(row).setId((Integer) value);
                break;
            case DESCRIPTION_INDEX:
                this.entities.get(row).setDescription((String) value);
                break;
        }
    }
}
